package com.tju.resource.oauth.controller.tb;

import com.tju.resource.annotation.Log;
import com.tju.resource.model.TbReportOrder;
import com.tju.resource.business.tb_report_order.TbReportOrderService;
import com.tju.resource.result.Result;
import com.tju.resource.tool.enum_utils.FunctionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 包装
 */
@RestController
public class TbPackingController {
    private static final String prefix = "packing";
    @Autowired
    private TbReportOrderService tbReportOrderService;

    /**
     * 查询包装
     * @param param 包装数据
     * @return
     */
    @Log(type= FunctionType.List)
    @PostMapping(prefix + "/list")
    @PreAuthorize("hasAuthority('sys:quality:packing:list')")
    public Result<Object> list(@RequestBody Map<String, String> param) {
        return tbReportOrderService.selectTbReportOrder(param);
    }

    /**
     * 报工包装
     * @param reportOrder
     * @return
     */
    @PostMapping(prefix + "/report")
    @PreAuthorize("hasAuthority('sys:quality:packing:report')")
    @Log(type= FunctionType.Report)
    public Result<Object> list(@RequestBody TbReportOrder reportOrder) {
        return tbReportOrderService.insertTbReportOrder(reportOrder);
    }
}
